package cn.kgc.springboot07.controller;

import cn.kgc.springboot07.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.Date;

/**
 * @author: mosin
 * @version: v1.0  2022/5/25
 */
@Controller
public class ThymeleafController {

    @RequestMapping("toindex")
    public String  toIndex(Model model){
        model.addAttribute("msg", "<span>hello world</span>");
        Student student = Student.builder().age(20).birth(new Date()).stuName("lisi").id(1).role("guster").build();
        model.addAttribute("student", student);

        ArrayList<Student> students = new ArrayList<>();
        students.add(student);
        students.add(student);
        students.add(student);
        students.add(student);
        students.add(student);
        students.add(student);

        model.addAttribute("students", students);

        model.addAttribute("role", "guster");

        return  "index";
    }

}
